﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link rel="stylesheet" href="Console/styles/main-styles.css" />
    <link href="Console/styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <h3>Write a JavaScript function reverses string and returns itExample: "sample"  "elpmas".</h3>

    <label for="tb-first">Input a string: </label>
    <input type="text" id="tb-first" />
    <div id="wrapper">
        <br />
        <a href="#" onclick="runProgram()">Run program!</a>
        <div id="console">
        </div>
    </div>
    <script src="Console/scripts/js-console.js">	  
	</script>
    <script>

        // Gets the user input
        function getInput() {
            var number = document.getElementById('tb-first').value;
            return number;
        }

        // reverse num
        function reverseNum(number) {
            number = String(number);
            var outStr = "";
            for (var i = number.length - 1; i >= 0; i--) {
                outStr += number[i];
            }

            return outStr;
        }

        //run program
        function runProgram() {
            var number = getInput();
            jsConsole.writeLine(reverseNum(number));
        }
	</script>
</body>
</html>
